import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.alibaba.fastjson.JSON;
import com.aliyun.odps.udf.UDF;

public class SpliderMatchEnglishOrJapanese extends UDF{
	/*
	 * public static void main(String[] args) { evaluate("ヒアロオリゴ®"); }
	 */
	
	public String evaluate(String title) {
		Map<String, String> result = new HashMap<String, String>();
		Set<Character.UnicodeBlock> japaneseUnicodeBlocks = new HashSet<Character.UnicodeBlock>() {
			{
				add(Character.UnicodeBlock.HIRAGANA);
				add(Character.UnicodeBlock.KATAKANA);
				add(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS);
			}
		};

		for (char c : title.toCharArray()) {
			if (japaneseUnicodeBlocks.contains(Character.UnicodeBlock.of(c))) {
				result.put("jpTitle", title);
				System.out.println(c + " is a Japanese character");
				break;
			}else {
				result.put("enTitle", title);
			}
		}
		System.out.println(JSON.toJSONString(result));
		return JSON.toJSONString(result);
	}
	
}
